package com.mate.cloud.sensitive.processor;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.SM4;

/**
 * @description: SM4加密解密
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2025/2/11 17:59
 * @updateUser: MI
 * @updateTime: 2025/2/11 17:59
 * @updateRemark: 修改内容
 * @version: v1.0
 */
public class SM4Processor implements SecurityProcessor {

    private String secret;

    private SM4 sm4;


    public SM4Processor(String secret) {
        this.secret = secret;
        this.sm4=new SM4(SecureUtil.decode(secret));
    }


    @Override
    public byte[] decrypt(String text) {
        return sm4.decrypt(text);
    }

    @Override
    public byte[] encrypt(byte[] data) {
        return sm4.encrypt(data);
    }
}
